package main

import (
	"fmt"
	"sync"
	"time"
)

var wg sync.WaitGroup

func main() {
	//定义一个int类型的管道
	var intChan chan int
	intChan = make(chan int, 3)
	go func() {
		time.Sleep(time.Second * 5)
		intChan <- 10
		intChan <- 20
		intChan <- 30
	}()
	//定义一个string类型的管道
	var stringChan chan string
	stringChan = make(chan string, 3)
	go func() {
		time.Sleep(time.Second * 2)
		stringChan <- "a"
		stringChan <- "b"
		stringChan <- "c"
		close(stringChan)
	}()

	//fmt.Println(<-intChan)
	select {
	case v := <-intChan:
		fmt.Printf("从intChan读取的数据%d\n", v)
	case v := <-stringChan:
		fmt.Printf("从stringChan读取的数据%s\n", v)
	default:
		fmt.Println("都取不到数据")
	}
}
